<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/admin/jsp/taglibs.jsp"%>
<html>
	<head>
		<%@ include file="/admin/jsp/header.jsp"%>
		<%@ include file="/framework/jsp/validation.jsp"%>
		<script language="javascript" src="/framework/js/tips_alert.js"></script>
		<script src="/framework/js/jquery.js" type="text/javascript"></script>
	</head>
	<body>
		<table width="98%" border="0" align="center" cellpadding="3"
			cellspacing="0">
			<tr>
				<td class="page-title">
					<img src="../images/page_title.gif" alt="title" width="17"
						height="12" align="absmiddle">
					&nbsp;&nbsp; 组织管理 » 单位管理 » 单位新增
				</td>
			</tr>
		</table>
		<br>
		<form id="form" action="/admin/jsp/corpMgr.do?method=saveDept"
			method="post">
			<input type="hidden" name="corpType" id="corpType" value="1">
			<input type="hidden" name="status" id="status" value="1">
			<table width="100%" border="0" align="center" cellpadding="5"
				cellspacing="0">
				<tr>
					<td></td>
					<td align="left">
						带
						<font color="red">&nbsp;*&nbsp;</font>为必填项
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>单位全称
					</td>
					<td>
						<input name="corpName" class="required max-length-25" type="text"
							id="corpName" size="20">
						<a href="#"><img src="../images/help.gif" tips="单位全称，25字以内"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>单位简称
					</td>
					<td>
						<input name="shortName" class="max-length-10" type="text"
							id="shortName" size="20">
						<a href="#"><img src="../images/help.gif" tips="单位简称，10字以内"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						上级单位
					</td>
					<td>
						<select name="parentCorpId" id="parentCorpId" onchange="queryRegion(this.value);">
							<option value="0">
								--无上级单位--
							</option>
							<c:forEach var="corp" items="${corpList}">
								<option value="<c:out value='${corp.corpId}'/>">
									<c:out value="${corp.corpName}" />
								</option>
							</c:forEach>
						</select>
						<a href="#"><img src="../images/help.gif" tips="上级单位"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>短信特服号
					</td>
					<td>
						<input name="smsSpCode" class="max-length-20" type="text"
							id="smsSpCode" size="20">
						<a href="#"><img src="../images/help.gif" tips="短信特服号，20字以内"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>彩信特服号
					</td>
					<td>
						<input name="mmsSpCode" class="max-length-20" type="text"
							id="mmsSpCode" size="20">
						<a href="#"><img src="../images/help.gif" tips="彩信特服号，20字以内"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>地区范围
					</td>
					<td>
						<div id="regionRange">
							<c:forEach var="region" items="${regionList}">
								<input class="validate-one-required" type="checkbox"
									name="regionRanges" value="${region.regionId}">
								<c:out value="${region.regionName}" />
							</c:forEach>
						</div>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>联系人
					</td>
					<td>
						<input name="contactName" class="required max-length-10"
							type="text" id="contact" size="20">
						<a href="#"><img src="../images/help.gif" tips="联系人，10字以内"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>移动电话
					</td>
					<td>
						<input name="tel" class="required validate-mobile-phone"
							type="text" id="telephone" size="20">
						<a href="#"><img src="../images/help.gif" tips="输入11位手机号码"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>Email
					</td>
					<td>
						<input name="email" class="validate-email" type="text" id="email" size="20">
						<a href="#"><img src="../images/help.gif" tips="Email，200字以内"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						描述信息
					</td>
					<td>
						<textarea name="corpDesc" rows="4" cols="40" id="corpDesc"
							class="max-length-200"></textarea>
						<a href="#"><img src="../images/help.gif" tips="单位描述，200字以内"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="center" valign="middle" colspan="2">
						<input type="submit" class="short-button" value="提  交" />
						<input type="button" class="short-button" value="返  回"
							onclick="window.location='/admin/jsp/corpMgr.do?method=queryCorp'" />
					</td>
				</tr>
			</table>

		</form>
	</body>
	<script>
		new Validation('form',{immediate:true});
		
		//根据单位ID获取单位对应的区域范围信息
		function queryRegion(corpId)
		{
			var html = $.ajax({ 
					type: "POST", 
    				url: "/admin/jsp/corpMgr.do?method=queryRegion", 
  					data: "corpId=" + corpId, 
    				dataType: "html",  
    				async: false, 
  					error: function (xhr, desc, exceptionobj) { 
      					alert(desc); 
    				},    
    				success: function(msg) {
    					document.getElementById("regionRange").innerHTML = msg;
    				} 
				}); 
		}
	</script>
</html>